//
//  BuZhuJinPeiJianInfoCell.m
//  FactorySale
//
//  Created by 李 on 2020/3/26.
//  Copyright © 2020 主事丫环. All rights reserved.
//

#import "BuZhuJinPeiJianInfoCell.h"
#import "SYBigImage.h"

@interface BuZhuJinPeiJianInfoCell ()

@property(nonatomic,strong) UILabel *pinLeiLab;
@property(nonatomic,strong) UILabel *nameContentLab;
@property(nonatomic,strong) UILabel *typeContentLab;
@property(nonatomic,strong) UILabel *buZhuJinContentLab;
@property(nonatomic,strong) UILabel *youXiaoQiWordLab;
@property(nonatomic,strong) UILabel *anZhuangTimeLab;
@property(nonatomic,strong) UILabel *erWeiMaTimeLab;
@property(nonatomic,strong) UILabel *baoZhiQiLab;
@property(nonatomic,strong) UILabel *pingZhengWordLab;
@property(nonatomic,strong) UILabel *sqshTimeLab;

@end

@implementation BuZhuJinPeiJianInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
}

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        
        
        //配件名称：
        UILabel *nameWordLab = [[UILabel alloc] init];
        nameWordLab.frame = CGRectMake(39, 13, 12*5, 12);
        nameWordLab.font = KFontPingFangSCRegular(12);
        nameWordLab.textColor = K333333;
        nameWordLab.text = @"配件名称：";
        [self.contentView addSubview:nameWordLab];
        
        UILabel *nameContentLab = [[UILabel alloc] init];
        nameContentLab.frame = CGRectMake(nameWordLab.right, 13, KWIDTH-39-12*5, 12);
        nameContentLab.font = KFontPingFangSCRegular(12);
        nameContentLab.textColor = K666666;
        nameContentLab.text = @"";
        [self.contentView addSubview:nameContentLab];
        self.nameContentLab = nameContentLab;
        
        //配件型号：
        UILabel *typeLab = [[UILabel alloc] init];
        typeLab.frame = CGRectMake(39, nameContentLab.bottom + 15, 12*5, 12);
        typeLab.font = KFontPingFangSCRegular(12);
        typeLab.textColor = K333333;
        typeLab.text = @"配件型号：";
        [self.contentView addSubview:typeLab];
        
        UILabel *typeContentLab = [[UILabel alloc] init];
        typeContentLab.frame = CGRectMake(typeLab.right, nameContentLab.bottom + 15, KWIDTH-39-12*5, 12);
        typeContentLab.font = KFontPingFangSCRegular(12);
        typeContentLab.textColor = K666666;
        typeContentLab.text = @"";
        [self.contentView addSubview:typeContentLab];
        self.typeContentLab = typeContentLab;
        
        //损坏补助金：
        UILabel *buZhuJinWordLab = [[UILabel alloc] init];
        buZhuJinWordLab.frame = CGRectMake(39, typeLab.bottom+15, 12*7, 12);
        buZhuJinWordLab.font = KFontPingFangSCRegular(12);
        buZhuJinWordLab.textColor = K333333;
        buZhuJinWordLab.text = @"工时费补助金：";
        [self.contentView addSubview:buZhuJinWordLab];
        
        UILabel *buZhuJinContentLab = [[UILabel alloc] init];
        buZhuJinContentLab.frame = CGRectMake(buZhuJinWordLab.right, typeLab.bottom+15, KWIDTH-39-12*7, 12);
        buZhuJinContentLab.font = KFontPingFangSCRegular(12);
        buZhuJinContentLab.textColor = K666666;
        buZhuJinContentLab.text = @"";
        [self.contentView addSubview:buZhuJinContentLab];
        self.buZhuJinContentLab = buZhuJinContentLab;
        
        //补助金有效期：3个月
        UILabel *youXiaoQiWordLab = [[UILabel alloc] init];
        youXiaoQiWordLab.frame = CGRectMake(39, buZhuJinWordLab.bottom+15, KWIDTH-39, 12);
        youXiaoQiWordLab.font = KFontPingFangSCRegular(12);
        youXiaoQiWordLab.textColor = [UIColor colorWithHexString:@"#F6A44B"];
        youXiaoQiWordLab.text = @"候保工时费补贴期：";
        [self.contentView addSubview:youXiaoQiWordLab];
        self.youXiaoQiWordLab = youXiaoQiWordLab;
        
        // 安装日期：
        UILabel *anZhuangTimeWordLab = [[UILabel alloc] init];
        anZhuangTimeWordLab.frame = CGRectMake(39, youXiaoQiWordLab.bottom+15, 12*5, 12);
        anZhuangTimeWordLab.font = KFontPingFangSCRegular(12);
        anZhuangTimeWordLab.textColor = K333333;
        anZhuangTimeWordLab.text = @"安装日期：";
        [self.contentView addSubview:anZhuangTimeWordLab];
        
        UILabel *anZhuangTimeLab = [[UILabel alloc] init];
        anZhuangTimeLab.frame = CGRectMake(nameWordLab.right, youXiaoQiWordLab.bottom+15, KWIDTH-39-14*5, 12);
        anZhuangTimeLab.font = KFontPingFangSCRegular(12);
        anZhuangTimeLab.textColor = K666666;
        anZhuangTimeLab.text = @"";
        [self.contentView addSubview:anZhuangTimeLab];
        self.anZhuangTimeLab = anZhuangTimeLab;
        
        // 申请损坏日期：
        UILabel *sqshTimeWordLab = [[UILabel alloc] init];
        sqshTimeWordLab.frame = CGRectMake(39, anZhuangTimeWordLab.bottom+15, 12*7, 12);
        sqshTimeWordLab.font = KFontPingFangSCRegular(12);
        sqshTimeWordLab.textColor = K333333;
        sqshTimeWordLab.text = @"申请损坏日期：";
        [self.contentView addSubview:sqshTimeWordLab];
        
        UILabel *sqshTimeLab = [[UILabel alloc] init];
        sqshTimeLab.frame = CGRectMake(sqshTimeWordLab.right, anZhuangTimeWordLab.bottom+15, KWIDTH-39*2-12*7, 12);
        sqshTimeLab.font = KFontPingFangSCRegular(12);
        sqshTimeLab.textColor = K666666;
        sqshTimeLab.text = @"";
        [self.contentView addSubview:sqshTimeLab];
        self.sqshTimeLab = sqshTimeLab;
        
        //二维码有效期：
        UILabel *erWeiMaTimeWordLab = [[UILabel alloc] init];
        erWeiMaTimeWordLab.frame = CGRectMake(39, sqshTimeWordLab.bottom+15, 12*9, 12);
        erWeiMaTimeWordLab.font = KFontPingFangSCRegular(12);
        erWeiMaTimeWordLab.textColor = K333333;
        erWeiMaTimeWordLab.text = @"候保二维码有效期：";
        [self.contentView addSubview:erWeiMaTimeWordLab];
        
        
        UILabel *erWeiMaTimeLab = [[UILabel alloc] init];
        erWeiMaTimeLab.frame = CGRectMake(erWeiMaTimeWordLab.right, sqshTimeWordLab.bottom+15, KWIDTH-39-12*9, 12);
        erWeiMaTimeLab.font = KFontPingFangSCRegular(12);
        erWeiMaTimeLab.textColor = K666666;
        erWeiMaTimeLab.text = @"";
        [self.contentView addSubview:erWeiMaTimeLab];
        self.erWeiMaTimeLab = erWeiMaTimeLab;
        
        //产品保质期：
        UILabel *baoZhiQiWordLab = [[UILabel alloc] init];
        baoZhiQiWordLab.frame = CGRectMake(39, erWeiMaTimeWordLab.bottom+15, 12*6, 12);
        baoZhiQiWordLab.font = KFontPingFangSCRegular(12);
        baoZhiQiWordLab.textColor = K333333;
        baoZhiQiWordLab.text = @"无忧质保期：";
        [self.contentView addSubview:baoZhiQiWordLab];
        
        UILabel *baoZhiQiLab = [[UILabel alloc] init];
        baoZhiQiLab.frame = CGRectMake(baoZhiQiWordLab.right, erWeiMaTimeWordLab.bottom+15, KWIDTH-39-12*6, 12);
        baoZhiQiLab.font = KFontPingFangSCRegular(12);
        baoZhiQiLab.textColor = K666666;
        baoZhiQiLab.text = @"";
        [self.contentView addSubview:baoZhiQiLab];
        self.baoZhiQiLab = baoZhiQiLab;
        
        //安装凭证
        UILabel *pingZhengWordLab = [[UILabel alloc] init];
        pingZhengWordLab.frame = CGRectMake(39, baoZhiQiWordLab.bottom+15, KWIDTH-39, 12);
        pingZhengWordLab.font = KFontPingFangSCRegular(12);
        pingZhengWordLab.textColor = K333333;
        pingZhengWordLab.text = @"初始安装完工照片";
        [self.contentView addSubview:pingZhengWordLab];
        self.pingZhengWordLab = pingZhengWordLab;
    }
    return self;
}
-(void)setModel:(GrantDetailContentModel *)model
{
    _model =model;
    if (_model) {
        
        
        self.pinLeiLab.text = model.type_name;//    配件品类
        self.nameContentLab.text = model.parts_name;
        self.typeContentLab.text = model.att_name; //配件型号
        self.buZhuJinContentLab.text =[NSString stringWithFormat:@"¥%@",model.compensationPrice];
        self.youXiaoQiWordLab.text =[NSString stringWithFormat:@"候保工时费补贴期：%@个月",model.warranty];
        self.anZhuangTimeLab.text = model.installDate;
        self.sqshTimeLab.text = model.createTime;
        self.erWeiMaTimeLab.text = model.install;
        self.baoZhiQiLab.text = [NSString stringWithFormat:@"%@个月",model.freeWarranty];

        
        //照片背景 View
        UIView *imageBackView = [[UIView alloc] init];
        imageBackView.frame = CGRectMake(32.5, self.pingZhengWordLab.bottom + 5, KWIDTH-65, 75);
        [self.contentView addSubview:imageBackView];
        self.imageBackView = imageBackView;

        NSString *imagesStr = self.model.installImg;
        NSArray *imagearr = [imagesStr componentsSeparatedByString:@"|"];
        CGFloat wei = (KWIDTH-25-46-46)/4;

        if (imagearr.count > 0) {
            [self.imageBackView removeAllSubviews];
            for (int i = 0; i < imagearr.count; i++) {
                UIImageView *myimage = [[UIImageView alloc]init];
                [self.imageBackView addSubview:myimage];
                [myimage sd_setImageWithURL:[NSURL URLWithString:imagearr[i]] placeholderImage:defaultImg];
                myimage.frame = CGRectMake((wei+10)*(i % 4)+10, (wei + 10) * (i / 4)+5, wei, wei);
                myimage.userInteractionEnabled = YES;
                SYBigImage * bigI = [[SYBigImage alloc]init];
                [myimage addGestureRecognizer:bigI];
                self.imageBackView.frame = CGRectMake(32.5, self.pingZhengWordLab.bottom + 5, self.contentView.width - 65, (wei + 10) * (i / 4 + 1));
            }
        }
    }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
